package com.wr.service.impl;

import com.wr.dao.SessionEntityMapper;
import com.wr.model.SessionEntity;
import com.wr.service.SessionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author WuRui
 * @Date 2017/5/19 0019
 */
@Service("sessionService")
public class SessionServiceImpl implements SessionService {

    @Resource
    private SessionEntityMapper sessionEntityMapper;

    @Override
    public SessionEntity selectSessionByMobile(String mobile) {
        List<SessionEntity> list = sessionEntityMapper.selectByMobile(mobile);
        if(list.size() > 0){
            return list.get(0);
        }
        return null;
    }

    @Override
    public void deleteSessionByMobile(String mobile) {
        sessionEntityMapper.deleteByMobile(mobile);
    }

    @Override
    public void deleteAll(){
        sessionEntityMapper.deleteAll();
    }

    @Override
    public void insertSessionEntity(SessionEntity sessionEntity) {
        sessionEntityMapper.insert(sessionEntity);
    }
}
